package com.dc.java8._1_lambda;

/**
 * Description: 创建线程的 Lambda 实现方式
 * @author: gdc
 * @date: 2021/4/10
 * @version 1.0
 */
public class LambdaTest2 implements Runnable {
	@Override
	public void run() {
		
		new Thread(new Runnable() {
			@Override
			public void run() {
				System.out.println("hello world!<1>");
			}
		}).start();
		
		// 使用 lambda 表达式
		new Thread(() -> System.out.println("hello world!<2>")).start();
		
		// 使用匿名内部类
		Runnable race1 = new Runnable() {
			@Override
			public void run() {
				System.out.println("hello world!<3>");
			}
		};
		// 使用Lambda 表达式
		Runnable race2 = () -> System.out.println("hello world!<4>");
		
		race1.run();
		race2.run();
	}
	
	public static void main(String[] args) {
		LambdaTest2 lambdaTest2 = new LambdaTest2();
		Thread thread = new Thread(lambdaTest2, "test线程");
		thread.start();
		
	}
	
	
	
	
}
